package com.fxc;

public class WorkThree {
	
	public static void main(String[] args) {
		// 三种方法计算1-100的总和
		// sumOne();
		// sumTwo();	
		// int sumThree = sumThree(1);
		// System.out.println("three计算1-100的总和:" + sumThree);
		
		// printNum();
		// multiplicationTable();
		// rightTriangle();
		oddSum();
	}
	
	private static void oddSum() {
		
		int sum = 0;
		
		for ( int i  = 100; i <= 10000; i++) {
			
			if (i % 2 == 0) {
				
				sum += i;
				
			}
		}
		
		System.out.println("1-100奇数的和" + sum);
	}

	private static void rightTriangle() {
		for (int i = 0; i < 10; i++) {
			for (int j = 0; j <i; j++) {
				System.out.print(" * ");
			}
			System.out.println();
		}
	}

	public static void multiplicationTable () {
		int i, j;
		
		for (i = 1; i <= 9; i++) {
			for ( j = 1; j <= i; j++) {
				System.out.print(i +" * " + j  + " = " + i * j);
				System.out.print("\t");
			}
			System.out.println();
		}
		
		
	}
	
	public static void printNum() {
		for (int i = 1; i <= 100; i++) {
			System.out.print(i + "\t");
			if (i %5 == 0 ) {
				System.out.println();
			}
		}
	}
	
	public static  void sumOne() {
		
		int sum = 0;
		
		for (int i = 1; i <= 100; i++) {
			sum += i;
		}
		
		System.out.println("one计算1-100的总和:" + sum);
	}
	
	public static void sumTwo() {
		
		int sum = 0;
		
		int i = 1;
		
		while (i <=100) {
			sum += i;
			i++;
		}
		
		System.out.println("two计算1-100的总和:" + sum);
		
	}
	
	private static  int sumThree(int i) {
		
		int sum = 0;
		
		if (i > 100) {
			return sum;
		}
		sum = sumThree(i+1) + i;
		
		return sum;
	}
}

